<?php #//v.3.3.0

#///////////////////////////////////////////////////////
#//  COPYRIGHT 2004 Phpauction.org ALL RIGHTS RESERVED//
#///////////////////////////////////////////////////////

require('../includes/config.inc.php');
include "loggedin.inc.php";

//-- Set offset and limit for pagination
$limit = 20;
if(!$_GET[offset]) {
  $offset = 0;
} else {
  $offset = $_GET[offset];
}
$_SESSION['RETURN_LIST'] = 'listauctions.php';
$_SESSION['RETURN_LIST_OFFSET'] = intval($_GET['offset']);

?>
<HTML>
<HEAD>
<link rel='stylesheet' type='text/css' href='style.css' />
<link href="css/main.css" rel="stylesheet" type="text/css">
</HEAD>
<bodyleftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="titulo">
        <tr>
          <td class="icono"><img src="images/auction_icon2.gif" width="31" height="25" ></td>
          <td class="breadcrumbs"><p><span><?=$MSG_239?></span>&nbsp;&gt;&gt;&nbsp;<?=$MSG_067?></p></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
  </tr>
  <tr>
    <td align="center" valign="middle"><TABLE WIDTH="95%" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER" class="base" style="border:1px solid #ccc;">
        <TR>
          <TD ALIGN=CENTER class=title><p><? print $MSG_067; ?></p></TD>
        </TR>
        <TR>
          <TD><TABLE WIDTH=100% CELPADDING=0 CELLSPACING=0 BORDER=0 ALIGN="CENTER" CELLPADDING="0">
              <?
              $query = "select count(id) as auctions from PHPAUCTIONXL_auctions WHERE closed='0' ";
              $result = mysql_query($query);
              if(!$result){
              	print "$ERR_001<BR>$query<BR>".mysql_error();
              	exit;
              }
              $num_auctions = mysql_result($result,0,"auctions");
              print "<TR BGCOLOR=#FFFFFF>
				<TD COLSPAN=7>
				<B>
				$num_auctions $MSG_311</B> 
		  		</TD>
				</TR>";
	?>
              <TR BGCOLOR="#FFFFC0" style="color:#000;">
                <TD ALIGN=CENTER> <B> <? print $MSG_312; ?> </B>  </TD>
                <TD ALIGN=CENTER> <B> <? print $MSG_313; ?> </B>  </TD>
                <TD ALIGN=CENTER> <B> <? print $MSG_314; ?> </B>  </TD>
                <TD ALIGN=CENTER> <B> <? //print $MSG_315; ?> </B>  </TD>
                <TD ALIGN=LEFT> <B> <? print $MSG_316; ?> </B>  </TD>
                <TD ALIGN=LEFT> <B> <? print $MSG_317; ?> </B>  </TD>
                <TD ALIGN=CENTER> <B> <? //print $MSG_315; ?> </B>  </TD>
                <TD ALIGN=LEFT> <B> <? print $MSG_297; ?> </B>  </TD>
              <TR>
                <?
                $query = "SELECT DISTINCT(a.id), u.nick, a.refund, a.title, a.starts, a.description, a.suspended,
                			c.cat_name 
                			FROM 	PHPAUCTIONXL_auctions a, 
                					PHPAUCTIONXL_users u, 
                					PHPAUCTIONXL_categories c
                			WHERE u.id = a.user 
                			AND c.cat_id = a.category 
                		 
                			AND a.closed!='1' 
                			ORDER BY nick limit $offset, $limit";
               
                $result = mysql_query($query);
               
               
                if(!$result){
                	print "Database access error: abnormal termination<BR>$query<BR>".mysql_error();
                	exit;
                }
                
                $num_auction = mysql_num_rows($result);
                $i = 0;
                $bgcolor = "#FFFFFF";
                while($i < $num_auction){
                	
                	if($bgcolor == "#FFFFFF"){
                		$bgcolor = "#EEEEEE";
                	}else{
                		$bgcolor = "#FFFFFF";
                	}
                	$id = mysql_result($result,$i,"id");
                	$title = stripslashes(mysql_result($result,$i,"title"));
                	$nick = mysql_result($result,$i,"nick");
                	$tmp_date = mysql_result($result,$i,"starts");
                	//$duration = mysql_result($result,$i,"duration");
                	$category = mysql_result($result,$i,"cat_name");
                	$description = strip_tags(stripslashes(mysql_result($result,$i,"description")));
                	$suspended = mysql_result($result,$i,"suspended");
                	$refund = mysql_result($result,$i,"refund");
                	$day = substr($tmp_date,6,2);
                	$month = substr($tmp_date,4,2);
                	$year = substr($tmp_date,0,4);
                	$date = "$day/$month/$year";
			?>
              <TR BGCOLOR="<?=$bgcolor?>">
                <TD>
                  <?
                  if($suspended == 1) {
                  	print "<FONT COLOR=red><B>$title</B>";
                  } else {
                  	print $title;
                  }
			?>
                   </TD>
                <TD>
                  <?=$nick?></TD>
                <TD>
                  <?=$date?>
                  </TD>
                <TD>
                  <?//=$duration?>
                  </TD>
                <TD>
                  <?=$category?>
                  </TD>
                <TD>
                  <?=$description?>
                  </TD> 
                    	<TD>
						<A href="../relistauction.php?id=<? print $id; ?>" ><? print $MSG_AJAX_ADMIN_LIST_CLOSED_RELIST_ITEM; ?></a>
												</TD>
              <!-- <TD ALIGN=LEFT><A HREF="editauction.php?id=<?=$id?>&offset=<?=$offset?>" class="nounderlined">  -->
                      <TD ALIGN=LEFT><A HREF="../edit_active_auction.php?id=<?=$id?>" class="nounderlined">
                  <?=$MSG_298?>
                  </A><BR>
                  <A HREF="deleteauction.php?id=<?=$id?>&offset=<?=$offset?>" class="nounderlined">
                  <?=$MSG_299?>
                  </A><BR>
                  <A HREF="excludeauction.php?id=<?=$id?>&offset=<?=$offset?>" class="nounderlined">
                  <?
                  if($suspended == 0) {
                  	print $MSG_300;
                  } else {
                  	print $MSG_310;
                  }
                       	print "</A><BR>";
                    if($refund == 0 ) {
          
          print "<A HREF=\"refund_bids_for_an_entire_auction.php?id=$id\" class=\"nounderlined\">$MSG_AJAX_ADMIN_AUCTION_REFUND_BIDS_FOR_AUCTION2</A><BR>";
						               }
						               
						                if($refund == 1 ) {
          
          print "<font color=red >$MSG_AJAX_ADMIN_AUCTION_REFUND_BIDS_FOR_AUCTION3</font><BR>";
						               }
						               
					print "<A HREF=\"../complete_history.php?id=$id\" class=\"nounderlined\">Bid History</A><BR>";
						               
						               
						               
						               
			?>
                                </TD>
              <TR>
                <?
                $i++;
                }
		?>
            </TABLE></TD>
        </TR>
      </TABLE>
      <TABLE WIDTH=600 BORDER=0 CELLPADDING=4 CELLSPACING=0 ALIGN=CENTER>
        <TR ALIGN=CENTER BGCOLOR=#FFFFFF>
          <TD COLSPAN=2><SPAN CLASS="navigation">
            <?
            $num_pages = ceil($num_auctions / $limit);
            $i = 0;
            while($i < $num_pages ){
            	
            	$of = ($i * $limit);
            	
            	if($of != $offset){
            		print "<A HREF=\"listauctions.php?offset=$of\" CLASS=\"navigation\">".($i + 1)."</A>";
            		if($i != $num_pages) print " | ";
            	}else{
            		print $i + 1;
            		if($i != $num_pages) print " | ";
            	}
            	
            	$i++;
            }
	  ?>
            </SPAN> </TD>
        </TR>
      </TABLE></TD>
  </TR>
</TABLE>
</td>
</tr>
</table>
</BODY>
</HTML>
